from rest_framework import serializers

from operator_log.models import OperatorLog
from users.models import User


class UserSerializer(serializers.ModelSerializer):
    """用户显示"""

    class Meta:
        model = User
        fields = ["username"]


class OperatorLogSerializer(serializers.ModelSerializer):
    """日志显示"""
    user = UserSerializer()
    action_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)

    class Meta:
        model = OperatorLog
        fields = "__all__"
